/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package proj2;
import java.math.*;
/**
 * The Default method for calculating e
 * @author Yerong
 */
public class E1 {
    private BigDecimal result;
    public E1()
    {
        result=BigDecimal.ONE;
    }
        public BigDecimal calculate(int n)
    {
        int it= 0;
        // term is the indivial term in the summation
        BigDecimal term = BigDecimal.ONE;
        for (it = 0; it < n; it++) {
            term = term.divide(new BigDecimal(it+1), 100, RoundingMode.CEILING);        
            result = result.add(term);
        }
        return result;
    }
    
}
